package com.erpanderp.wam.asset.view;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import com.erpanderp.wam.asset.model.entity.AssetDetails;
import com.erpanderp.wam.asset.model.entity.AssetRequest;
import com.erpanderp.wam.asset.model.service.AssetRequestDAO;

@ManagedBean
@ViewScoped
public class ViewAssetRequestsBean implements Serializable {

	private static final long serialVersionUID = 1L;
	private HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
	ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
  
	private AssetRequestDAO assetRequestDAO =new AssetRequestDAO();
	
	private AssetRequest assetRequest =new AssetRequest();
	
	private List<AssetDetails> assetDetailsList = new ArrayList<AssetDetails>(); 

	private String assetCode;
	
	public ViewAssetRequestsBean() {
		assetCode=request.getParameter("assetCode");
		assetRequest = assetRequestDAO.getAssetRequestByAssetCode(assetCode);
		
		assetDetailsList = assetRequestDAO.getAllAssetDetailsByAssetCode(assetRequest.getAssetRequestId());
	}

	//GENERATE SETTERS and GETTERS 	
	public AssetRequestDAO getAssetRequestDAO() {
		return assetRequestDAO;
	}


	public void setAssetRequestDAO(AssetRequestDAO assetRequestDAO) {
		this.assetRequestDAO = assetRequestDAO;
	}

	public AssetRequest getAssetRequest() {
		return assetRequest;
	}

	public void setAssetRequest(AssetRequest assetRequest) {
		this.assetRequest = assetRequest;
	}

	public List<AssetDetails> getAssetDetailsList() {
		return assetDetailsList;
	}

	public void setAssetDetailsList(List<AssetDetails> assetDetailsList) {
		this.assetDetailsList = assetDetailsList;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public String getAssetCode() {
		return assetCode;
	}

	public void setAssetCode(String assetCode) {
		this.assetCode = assetCode;
	}

}
